home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 303_01.zip / UNC.H < prev   
Text File  |  1993-04-01  |  5KB  |  182 lines

  1. /*
  2.  *    SCCS:    %W%    %G%    %U%
  3.  *    Header file for uncompile program.
  4.  *
  5.  *EMACS_MODES:c
  6.  */
  7.  
  8. #define    MAXCHARS    50
  9. #define    HASHMOD        97
  10.  
  11. /*
  12.  *    The following structure is used to keep track of symbols.
  13.  */
  14.  
  15. struct    symstr    {
  16.     struct    symstr    *s_next;        /*  Next in hash chain  */
  17.     struct    symstr    *s_link;        /*  Next in duplicate labels */
  18. #ifdef    COFF
  19.     unsigned    s_type    :  5;        /*  Symbol type  */
  20. #else    /*  !COFF  */
  21.     unsigned    s_type    :  3;        /*  Symbol type  */
  22. #endif    /*  !COFF  */
  23.     unsigned    s_newsym:  1;        /*  A new symbol  */
  24.     unsigned    s_invent:  1;        /*  Invented symbol  */
  25.     unsigned    s_glob    :  1;        /*  Global symbol  */
  26.     long        s_value;        /*  Value if defined  */
  27.     short        s_defs;            /*  Defined count  */
  28.     short        s_used;            /*  Used count  */
  29.     unsigned short    s_lsymb;        /*  Local symbol  */
  30.     char        s_name[1];        /*  Chars of name null term */
  31. };
  32.  
  33. typedef    struct    symstr    *symbol;
  34.  
  35. symbol    symbhash[HASHMOD];
  36.  
  37. typedef    struct    {
  38.     int    ef_t;            /*  Text file fd  */
  39.     int    ef_d;            /*  Data file fd  */
  40.     long    ef_entry;        /*  Entry point  */
  41.     long    ef_tsize;        /*  Text size  */
  42.     long    ef_dsize;        /*  Data size  */
  43.     long    ef_bsize;        /*  Bss size  */
  44.     long    ef_end;            /*  End of it all  */
  45.     long    ef_tbase;        /*  Text base  */
  46.     long    ef_dbase;        /*  Data base  */
  47.     long    ef_bbase;        /*  Bss base  */
  48.     int    ef_stcnt;        /*  Number of symbols  */
  49.     int    ef_stmax;        /*  Max number of symbols  */
  50.     symbol    *ef_stvec;        /*  Symbol vector  */
  51. }  ef_fids;
  52.  
  53. typedef    ef_fids    *ef_fid;
  54.  
  55. /*
  56.  *    Description of word in text file.  This entry is held in the place
  57.  *    corresponding to the address in the text file.
  58.  */
  59.  
  60. typedef    struct    {
  61.     unsigned  short    t_contents;        /*  Actual contents  */
  62.     unsigned  short t_iindex;        /*  Index in table  */
  63.     unsigned    t_type    :  2;        /*  Type  */
  64.     unsigned    t_vins  :  1;        /*  Valid instruction  */
  65.     unsigned    t_bdest    :  1;        /*  Is branch dest  */
  66.     unsigned    t_gbdest:  1;        /*  Is global dest  */
  67.     unsigned    t_dref    :  1;        /*  Refered to in data  */
  68.     unsigned    t_bchtyp:  2;        /*  Branch type  */
  69. #ifdef    COFF
  70.     unsigned    t_zilch    :  3;        /*  used to be t_lng */
  71. #else    /*  !COFF  */
  72.     unsigned    t_lng    :  3;        /*  Length in words  */
  73. #endif    /*  !COFF  */
  74.     unsigned    t_reloc :  2;        /*  Relocatable  */
  75.     unsigned    t_rptr    :  2;        /*  Where relocated  */
  76.     unsigned    t_rdisp :  1;        /*  Relocatable displacement */
  77.     unsigned    t_isrel :  1;        /*  Relocated  */
  78.     unsigned    t_amap    :  1;        /*  Worked out  */
  79. #ifdef    COFF
  80.     short        t_lng;            /*  Length in words */
  81. #endif    /*  COFF  */
  82.     symbol        t_relsymb;        /*  Relocation symbol  */
  83.     long        t_reldisp;        /*  Offset + or - from symb */
  84.     symbol        t_lab;            /*  Label  */
  85.     unsigned  short    t_lsymb;        /*  Local symbol  */
  86.     long        t_reflo;        /*  Lowest place referred  */
  87.     long        t_refhi;        /*  Highest place referred  */
  88.     long        t_data;            /*  Data >= here  */
  89.     unsigned  short    t_match;        /*  Lib match lng  */
  90. }  t_entry;
  91.  
  92. /*
  93.  *    Types ......
  94.  */
  95.  
  96. #define    T_UNKNOWN    0
  97. #define    T_BEGIN        1
  98. #define    T_CONT        2
  99.  
  100. #define    R_NONE        0        /*  No relocation  */
  101. #define    R_BYTE        1        /*  Byte relocation  */
  102. #define    R_WORD        2        /*  Word relocation  */
  103. #define    R_LONG        3        /*  Long relocation  */
  104.  
  105. /*
  106.  *    Branch types.
  107.  */
  108.  
  109. #define    T_NOBR        0
  110. #define    T_CONDBR    1
  111. #define    T_UNBR        2
  112. #define    T_JSR        3
  113.  
  114. typedef    struct    {
  115.     unsigned  char    d_contents;        /*  Actual contents  */
  116.     unsigned    d_type  :  4;        /*  Data type  */
  117.     unsigned    d_reloc :  2;        /*  Relocatable  */
  118.     unsigned    d_rptr    :  2;        /*  Where relocated  */
  119.     short        d_lng;            /*  Length -ve for D_CONT */
  120.     symbol        d_relsymb;        /*  Relocation symbol  */
  121.     long        d_reldisp;        /*  Offset + or - from symb */
  122.     symbol        d_lab;            /*  Label  */
  123. }  d_entry;
  124.  
  125. /*
  126.  *    Data types.
  127.  */
  128.  
  129. #define    D_ASC        0        /*  Ascii chars  */
  130. #define    D_ASCZ        1        /*  Null-term ascii  */
  131. #define    D_BYTE        2        /*  Decimal bytes  */
  132. #define    D_WORD        3        /*  Words  */
  133. #define    D_LONG        4        /*  Longs  */
  134. #define    D_ADDR        5        /*  Address pointer  */
  135. #define    D_CONT        6        /*  Continuation of last  */
  136.  
  137. /*
  138.  *    'Common' items.
  139.  */
  140.  
  141. struct    commit    {
  142.     symbol    *c_symb;        /*  List of symbols  */
  143.     int    c_int;            /*  Current number  */
  144.     int    c_max;            /*  Maximum  */
  145. };
  146.  
  147. /*
  148.  *    Library file description.
  149.  */
  150.  
  151. struct    libit    {
  152. #ifdef    COFF
  153.     LDFILE *ldptr,*ldptr2;        /*  independent file pointer packages
  154.                         for the same file */
  155. #else    /*  !COFF  */
  156.     int    lf_fd;            /*  File descriptor  */
  157.     long    lf_offset;        /*  Offset of current file  */
  158.     long    lf_next;        /*  Offset of next file  */
  159. #endif    /*  !COFF  */
  160.     char    lf_name[14];        /*  Name of item  */
  161. };
  162.  
  163. #ifdef    COFF
  164. /* magic number stuff like Sun */
  165. #define OMAGIC 0407
  166. #define NMAGIC 0410
  167. #define ZMAGIC 0413
  168. #define N_BADMAG(x) \
  169.     (((x).magic)!=OMAGIC && ((x).magic)!=NMAGIC && ((x).magic)!=ZMAGIC)
  170.  
  171. /* definitions of type for Sun -- used for symstr.type, d_entry.d_rptr */
  172. #define S_UNDF 0x0        /* undefined */
  173. #define S_ABS  0x2        /* absolute */
  174. #define S_TEXT 0x4        /* text */
  175. #define S_DATA 0x6        /* data */
  176. #define S_BSS  0x8        /* bss */
  177. #define S_COMM 0x12        /* common (internal to ld) */
  178. #define S_FN   0x1f        /* file name symbol */
  179. #define S_EXT  01        /* external bit, or'ed in */
  180. #define S_TYPE 0x1e        /* mask for all the type bits */
  181. #endif    /*  COFF  */
  182.